#pragma once
#include <Dynamics/Integrator/integrator.h>

namespace PhysLeo {

/**
 * explicit symplectic euler cpu module
 * v = v + a*dt
 * x = x + v*dt
 */
template<typename T>
class SymplecticEulerCpu : public Integrator<T> {
public:
    /**
    * empty constructor
    */
    SymplecticEulerCpu() = default;

    /**
    * virtual destructor
    */
    virtual ~SymplecticEulerCpu() = default;

    /**
    * allocate resource for integrator and its submodule
    * @param[in] simData  simulation data
    */
    void allocateResource(SimData<T>& simData) override;

    /**
    * advance timestep dt
    * @param[in] dt timestep
    */
    void advanceTime(float dt) override;

protected:
    /**
     * position vector
     */
    std::shared_ptr<BufferData<glm::tvec3<T>>> ptr_pos_;

    /**
     * velocity vector
     */
    std::shared_ptr<BufferData<glm::tvec3<T>>> ptr_vel_;

    /**
     * force vector
     */
    std::shared_ptr<BufferData<glm::tvec3<T>>> ptr_force_;

    /**
     * mass vector
     */
    std::shared_ptr<BufferData<T>> ptr_mass_;
};

}